<?php
#PD 08-02-2012

/**
 * Klasa na potrzeby modulu testu pokazujacego autoryzacje ksiazka eazZend 186
 * Enter description here ...
 * @author damian
 *
 */
class User extends Zend_Db_Table
{

 /**
 * The actual name of the table
 *
 * @var string
 */
 protected $_name = 'users';

 /**
 * The table's primary key
 *
 * @var string
 */
 protected $_primary = 'id';

 /**
 * The User class' row model
 *
 */
 protected $_rowClass = 'UserRow';

 /**
 * Retrieve a user using his email address
 *
 * @param string $email
 * @return UserRow
 */
 function getUserByEmail($email)
 {
	 $query = $this->select();
	 $query->where('email = ?', $email);
	 $result = $this->fetchRow($query);
	 return $result;
 }

 /**
 * Retrieve user according to his gamer handle
 *
 * @param string $handle
 * @return UserRow
 */
 function getUserByHandle($handle)
 {
 $query = $this->select();
 $query->where('handle = ?', $handle);
 $result = $this->fetchRow($query);
 
 
 return $result;
 }

 /**
 * Calculate the total number of registered users
 *
 * @return integer
 */
 function getUserCount()
 {
 $query = $this->select('id');
 $result = $this->fetchAll($query);
 return count($result);
 }

 }
?>